package org.lyimg.com.imgapplication.activity;

import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;

import org.lyimg.com.imgapplication.R;
import org.lyimg.com.imgapplication.adapter.MainRecAdapter;
import org.lyimg.com.imgapplication.bean.ImgType;
import org.lyimg.com.imgapplication.presenter.mainPresenter;
import org.lyimg.com.imgapplication.view.ImainView;

import java.util.List;


public class MainActivity extends BaseActivity<ImainView,mainPresenter> implements ImainView {


    RecyclerView main_recycler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar =  findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        main_recycler = findViewById(R.id.main_recycler);
        //设置布局管理器
        main_recycler.setLayoutManager(new LinearLayoutManager(this));
        //设置Item增加、移除动画
        main_recycler.setItemAnimator(new DefaultItemAnimator());

        presenter.initData();
    }

    @Override
    protected mainPresenter creatPresenter() {
        return new mainPresenter();
    }


    @Override
    public void showloading() {
        showDialog();
    }

    @Override
    public void dissloading() {
        dismissDialog();
    }

    @Override
    public void showError(String msg) {
        Showtosat(msg);
    }

    @Override
    public void showData(List<ImgType> imgTypes) {
        main_recycler.setAdapter(new MainRecAdapter(MainActivity.this, imgTypes));
    }

}
